package com.wholesale.beans;

import org.json.JSONException;
import org.json.JSONObject;

public class Comment {

	private int commentId;
	private String addTime;
	private int commentRank;
	private int commentType;
	private String content;
	private String email;
	private int idValue;
	private int parentId;
	private int userId;
	private String userName;
	private boolean isReply;
	private JSONObject jsonObject;

	public int getCommentId() {
		return commentId;
	}

	public void setCommentId(int commentId) {
		this.commentId = commentId;
	}

	public boolean getReply() {
		return isReply;
	}

	public void setReply(boolean re) {
		this.isReply = re;
	}

	public String getAddTime() {

		return addTime;
	}

	public void setAddTime(String addTime) {
		this.addTime = addTime;
	}

	public int getCommentRank() {

		return commentRank;
	}

	public void setCommentRank(int commentRank) {
		this.commentRank = commentRank;
	}

	public int getCommentType() {

		return commentType;

	}

	public void setCommentType(int commentType) {
		this.commentType = commentType;
	}

	public String getContent() {

		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getEmail() {

		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public int getIdValue() {

		return idValue;
	}

	public void setIdValue(int idValue) {
		this.idValue = idValue;
	}

	public int getParentId() {

		return parentId;
	}

	public void setParentId(int parentId) {
		this.parentId = parentId;
	}

	public int getUserId() {

		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String getUserName() {

		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String toJsonString() {
		JSONObject jsonObject = new JSONObject();
		try {
			// jsonObject.put("addTime", addTime);
			jsonObject.put("commentRank", commentRank);
			jsonObject.put("commentType", commentType);
			jsonObject.put("content", content);
			jsonObject.put("email", email);
			jsonObject.put("idValue", idValue);
			jsonObject.put("parentId", parentId);
			jsonObject.put("userId", userId);
			jsonObject.put("userName", userName);
		} catch (Exception e) {
		}
		return jsonObject.toString();
	}

	public void jsonAnalytic(String jsonString) {

		try {
			jsonObject = new JSONObject(jsonString);
			jsonAnalytic(jsonObject);
		} catch (JSONException e) {
		}
	}

	public void jsonAnalytic(JSONObject jsonObject) {
		this.jsonObject = jsonObject;

		try {
			commentId = jsonObject.getInt("commentId");
		} catch (JSONException e) {

		}

		try {
			commentRank = jsonObject.getInt("commentRank");
		} catch (JSONException e) {

		}
		try {
			commentType = jsonObject.getInt("commentType");
		} catch (JSONException e) {

		}
		try {
			content = jsonObject.getString("content");
		} catch (JSONException e) {

		}
		try {
			email = jsonObject.getString("email");
		} catch (JSONException e) {

		}
		try {
			idValue = jsonObject.getInt("idValue");
		} catch (JSONException e) {

		}
		try {
			parentId = jsonObject.getInt("parentId");
		} catch (JSONException e) {

		}
		try {
			userName = jsonObject.getString("userName");
		} catch (JSONException e) {

		}
		try {
			userId = jsonObject.getInt("userId");
		} catch (JSONException e) {

		}
		try {
			addTime = jsonObject.getString("addTime");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
		}

	}
}
